#

| Chapter 16 Where Did I Put That? |

## 16.18 Listing Files You've Created/Edited Today

If your directory is full of files and you're trying to find out which files you've made changes to (and created) today, here's how. [4] Make a shell script that stores today's date in the shell's command-line parameters. Pipe the output of ls -l to an awk script. In the awk script, put the month (which was the second word in the date output) into the awk string variable m. Put the date into the awk integer variable d-use an integer variable so date outputs like `Jun 04` will match ls outputs like `Jun 4`. Print any line where the two dates match.

> [4] Using find with -mtime -1 (17.7) will list files modified within the last 24 hours. That's not quite the same thing.

>     #!/bin/sh
>     set `date`
>     ls -l |
>     awk "BEGIN { m = \"$2\"; d = $3 }
>     \$5 == m && \$6 == d && \$7 ~ /:/ {print}"

If your version of ls -l gives both the file's owner and group, change `$5` to `$6` and `$6` to `$7`. You can make your life simpler by getting sls (16.29)- it lets you set the output format (including the date format) exactly.

- JP

16.17 Getting Directory Name from a File's Pathname |  | 16.19 stree: Simple Directory Tree